package com.example.common.mapper;

import com.example.common.pojo.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Mapper
@Component
@CacheNamespace(blocking = true)
public interface IWorkShopMapper {

    @Insert("insert into workshop values(null,#{amount},#{sqmeter},#{level},#{price},#{id})")
    int insertWorkShop(BigDecimal amount,BigDecimal sqmeter,String level,BigDecimal price,Integer id);

    @Select("select * from workshop where id = #{id}")
    WorkShop getWorkShop(int id);

    @Update("update workshop set workshop_amount=#{amount},workshop_sqmetere=#{sqmeter},workshop_level=" +
            "#{level},price=#{price} where id={id}")
    int updateWorkShop(BigDecimal amount,BigDecimal sqmeter,String level,BigDecimal price,Integer id);

    @Insert("insert into office_room values(null,#{price},#{amount},#{sqmeter},#{level},#{id})")
    int insertOffice(BigDecimal price,BigDecimal amount,
                     BigDecimal sqmeter,String level,int id);

    @Select("select * from office_room where id = #{id}")
    OfficeRoom getOfficeRoom(int id);

    @Update("update office_room set office_price=#{price},office_amount=#{amount},office_sqmeter=#{sqmeter}," +
            "office_level=#{level} where id = #{id}")
    int updateOfficeRoom(BigDecimal price,BigDecimal amount,
                          BigDecimal sqmeter,String level,int id);
    @Insert("insert into brick_floor values(null,#{price},#{amount},#{sq},#{id})")
    int insertBrickFloor(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from brick_floor where id = #{id}")
    BrickFloor getBrickFloor(int id);

    @Update("update brick_floor set brick_price = #{price},brick_amount=#{amount},brick_sqmeter=#{sq} where id = #{id}")
    int updateBrickFloor(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Insert("insert into small_room values(null,#{price},#{amount},#{sq},#{id})")
    int insertSmallRoom(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from small_room where id=#{id}")
    SmallRoom getSmallRoom(int id);

    @Update("update small_room set room_price = #{price},room_amount=#{amount},room_sqmeter=#{sq} " +
            "where id = #{id}")
    int updateSmallRoom(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    /////////////////////////////////////////
    @Insert("insert into enclosing_wall values(null,#{price},#{amount},#{sq},#{id})")
    int insertEnclosingWall(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from enclosing_wall where id = #{id}")
    EnclosingWal getEnclosingWall(int id);

    @Update("update enclosing_wall set enclosing_price = #{price},enclosing_amount = #{amount}," +
            "enclosing_sqmeter = #{sq} where id  = #{id}")
    int updateEnclosingWall(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    ////////////////////////////////////////
    @Insert("insert into retaining_wall values(null,#{price},#{amount},#{sq},#{id})")
    int inseretRetainingWall(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from retaining_wall where id = #{id}")
    RetainWall getRetainingWall(int id);

    @Update("update retaining_wall set retaining_price = #{price},retaining_amount = #{amount}," +
            "retaining_sqmeter = #{sq} where id = #{id}")
    int updateRetainingWall(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    //////////////////////////////////////////
    @Insert("insert into cement_road values(null,#{price},#{amount},#{sq},#{id})")
    int insertCementRoad(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from cement_road where id = #{id}")
    CementRoad getCementRoad(int id);

    @Update("update cement_road set cementRoad_price = #{price},cementRoad_amount = #{amount}," +
            "cementRoad_sqmeter = #{sq} where id = #{id}")
    int updateCementRoad(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    ///////////////////////////////////////////
    @Insert("insert into cement_floor values(null,#{price},#{amount},#{sq},#{id})")
    int insertCementFloor(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from cement_floor where id = #{id}")
    CementFloor getCementFloor(int id);

    @Update("update cement_floor set cementfloor_price = #{price},cementfloor_amount" +
            "=#{amount},cementfloor_sqmeter = #{sq} where id = #{id}")
    int updateCementFloor(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    //////////////////////////////////////////
    @Insert("insert into asphalt_road values(null,#{price},#{amount},#{sq},#{id})")
    int insertAsphaltRoad(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from asphalt_road where id = #{id}")
    AsphaltRoad getAsphaltRoad(int id);

    @Update("update asphalt_road set asphaltRoad_price = #{price},asphaltRoad_amount = #{" +
            "amount},asphaltRoad_sqmeter = #{sq} where id = #{id}")
    int updateAsphaltRoad(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    /////////////////////////////////////////////
    @Insert("insert into slope_protection_wall values(null,#{price},#{amount},#{sq},#{id})")
    int insertSlopeProtectionWall(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);

    @Select("select * from slope_protection_wall where id=#{id}")
    SlopeProWall getSlopeproWall(int id );

    @Update("update slope_protection_wall set slope_amount = #{amount},slope_price=#{price}," +
            "slope_sqmeter = #{sq} where id = #{id}")
    int updateSlopeProWall(BigDecimal price,BigDecimal amount,BigDecimal sq,int id);
}
